<?php
return (function () {
    function post($html, string $title, string $body)
    {
        return $html->mark([
            'div',
            'id' => 'post-wrapper',
            'class' => 'post-wrapper',
            ['h1', $title],
            ['p', $body],
        ]);
    }

    function posts($html, int $n)
    {
        $posts = ['div', 'id' => 'post-list'];
        foreach (range(1, $n) as $i)
            $posts[] = post($html, "Title $i", "Body $i");
        return $html->mark($posts);
    }

    $config = new \phiction\config();
    $config->pretty = false;
    $config->debugging = false;
    $prod_html = new \phiction\html($config);
    $config->pretty = true;
    $config->debugging = true;
    $dev_html = new \phiction\html($config);

    return [
        'production' => function () use ($prod_html) {
            echo $prod_html->render(posts($prod_html, 5));
        },
        'dev' => function () use ($dev_html) {
            echo $dev_html->render(posts($dev_html, 2));
        },
        '!no-tag' => function () use ($prod_html) {
            echo $prod_html->render([]);
        },
    ];
})();

